package com.bestcem.xm.ticket.controller.vo.ticket.config;

import com.bestcem.xm.ticket.entity.mongo.NotifySetting;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import javax.annotation.Nullable;
import java.util.Objects;

/**
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/9/8 17:29
 */
@Data
public class NotifySettingWayVO {

    /**
     * 是否开启邮箱通知
     */
    @JsonProperty(value = "email")
    private Boolean email;

    /**
     * 是否开启短信通知
     */
    @JsonProperty(value = "sms")
    private Boolean sms;

    /**
     * 是否开启飞书通知
     */
    @JsonProperty(value = "feishu")
    private Boolean feiShu;

    /**
     * 是否开启企业微信通知
     */
    @JsonProperty(value = "wechatwork")
    private Boolean weChatWork;
    /**
     * 是否开启钉钉通知
     */
    @JsonProperty(value = "dingtalk")
    private Boolean dingtalk;

    @Nullable
    public static NotifySettingWayVO getInstance(NotifySetting.Way entity) {
        if (Objects.isNull(entity)) {
            return null;
        }
        NotifySettingWayVO data = new NotifySettingWayVO();
        data.setEmail(entity.getEmail());
        data.setSms(entity.getSms());
        data.setFeiShu(entity.getFeiShu());
        data.setWeChatWork(entity.getWeChatWork());
        data.setDingtalk(entity.getDingtalk());
        return data;
    }

    @Nullable
    public NotifySetting.Way toEntity() {
        NotifySetting.Way entity = new NotifySetting.Way();
        entity.setEmail(this.email);
        entity.setSms(this.sms);
        entity.setFeiShu(this.feiShu);
        entity.setWeChatWork(this.weChatWork);
        entity.setDingtalk(this.dingtalk);
        return entity;
    }
}
